package com.ruoyi.web.controller.exhibition;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.demo.domain.AcProjectInputRecord;
import com.ruoyi.demo.service.IAcProjectInputRecordService;

import jakarta.servlet.http.HttpServletResponse;

/**
 * 用户输入记录Controller
 * 
 * @author CMee
 * @date 2025-10-24
 */
@RestController
@RequestMapping("/demo/project_input_record")
public class AcProjectInputRecordController extends BaseController {
    @Autowired
    private IAcProjectInputRecordService acProjectInputRecordService;

    /**
     * 查询用户输入记录列表
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(AcProjectInputRecord acProjectInputRecord) {
        LambdaQueryWrapper<AcProjectInputRecord> lqw = new LambdaQueryWrapper<>();
        Page<AcProjectInputRecord> page = acProjectInputRecordService
            .page(Page.of(acProjectInputRecord.getPageNum(), acProjectInputRecord.getPageSize()), lqw);
        return getDataTable(page);
    }

    /**
     * 导出用户输入记录列表
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:export')")
    @Log(title = "用户输入记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AcProjectInputRecord acProjectInputRecord) {
        List<AcProjectInputRecord> list =
            acProjectInputRecordService.selectAcProjectInputRecordList(acProjectInputRecord);
        ExcelUtil<AcProjectInputRecord> util = new ExcelUtil<AcProjectInputRecord>(AcProjectInputRecord.class);
        util.exportExcel(response, list, "用户输入记录数据");
    }

    /**
     * 获取用户输入记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:query')")
    @GetMapping(value = "/{tableId}")
    public AjaxResult getInfo(@PathVariable("tableId") Long tableId) {
        return success(acProjectInputRecordService.selectAcProjectInputRecordByTableId(tableId));
    }

    /**
     * 新增用户输入记录
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:add')")
    @Log(title = "用户输入记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AcProjectInputRecord acProjectInputRecord) {
        return toAjax(acProjectInputRecordService.insertAcProjectInputRecord(acProjectInputRecord));
    }

    /**
     * 修改用户输入记录
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:edit')")
    @Log(title = "用户输入记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AcProjectInputRecord acProjectInputRecord) {
        return toAjax(acProjectInputRecordService.updateAcProjectInputRecord(acProjectInputRecord));
    }

    /**
     * 删除用户输入记录
     */
    @PreAuthorize("@ss.hasPermi('demo:project_input_record:remove')")
    @Log(title = "用户输入记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tableIds}")
    public AjaxResult remove(@PathVariable Long[] tableIds) {
        return toAjax(acProjectInputRecordService.deleteAcProjectInputRecordByTableIds(tableIds));
    }
}
